var zhongwen = ['你', '是个', '好人', '一个', '大'];
var yingwen = ["you", "lt's a", "Good person", "One", "large"];
var text_if = document.querySelector("#text_if");
var text_that = document.querySelector("#text_that");
var btn_if = document.querySelectorAll("#btn_if button");
var btn_that = document.querySelectorAll("#btn_that button");
var lang = 'zh';

function swap(){
	if(lang === 'zh'){
		lang = 'en'
	}else{
		lang = 'zh';
	}
	for(var i = 0; i<btn_if.length;i++){
		btn_if[i].classList.remove("btn-primary")
		btn_if[i].classList.remove("btn-light")
		btn_that[i].classList.remove("btn-primary")
		btn_that[i].classList.remove("btn-light")
	}
	switch(lang){
		case'en':
		btn_if[0].classList.add("btn-light");
		btn_if[1].classList.add("btn-primary");
		btn_that[0].classList.add("btn-light");
		btn_that[1].classList.add("btn-primary");
		break;
		case 'zh':
		btn_if[0].classList.add("btn-primary");
		btn_if[1].classList.add("btn-light");
		btn_that[0].classList.add("btn-primary");
		btn_that[1].classList.add("btn-light");
		break;
	}
}
function res(){
	for (var i in zhongwen){
		if(text_if.value === zhongwen[i]){
			text_that.value = yingwen[i];
			if(lang === 'en'){
				swap();
			}
		}
	}
	for(var i in yingwen){
		if (text_if.value === yingwen[i]){
			text_that.value = zhongwen[i];
			if(lang === 'zh'){
				swap();
			}
		}
	}
}
